Circuit for detecting numbers equal to a power of two on a data bus

ABSTRACT

There is disclosed a circuit for determining if an N-bit number is equal to a power of two. The circuit comprises: 1) a first stage of detection gates, each of the first stage detection gates capable of receiving a first data bit and a second data bit from the N-bit number and generating a first output bit and a second output bit, wherein the first and second output bits are 01 if the first and second data bits are different and are one of 00 and 11 if the first and second data bits are the same; and 2) a second stage of detection gates coupled to the outputs of the first stage of detection gates, each of the second stage detection gates receiving three of the first stage output bits and generating a first output bit and a second output bit, wherein the first and second output bits of the second stage detection gates are 01 if only one of the three first stage output bits is equal to Logic 1 and are one of 00 and 11 otherwise.

CROSS-REFERENCE TO RELATED APPLICATION

[0001] The present invention is related to that disclosed in U.S. Patent application Ser. No. [ATTY DOCKET NO. 00-C-070], entitled “CIRCUIT FOR DETERMINING THE NUMBER OF LOGICAL ONE VALUES ON A DATA BUS” and filed concurrently herewith. The above application is commonly assigned to the assignee of the present invention. The disclosure of this related patent application is hereby incorporated by reference into the present disclosure as if fully set forth herein.

TECHNICAL FIELD OF THE INVENTION

[0002] The present invention is directed, in general, to data processors and, more specifically, to a circuit that determines whether or not a number on a data bus is a power of two.

BACKGROUND OF THE INVENTION

[0003] The demand for high performance computers and communication devices requires that state-of-the-art digital signal processors (DSPs) and general purpose microprocessors, such as ×86 based microprocessors, execute instructions in the minimum amount of time. A number of different approaches have been taken to decrease instruction execution time, thereby increasing processor throughput. One way to increase processor throughput is to use a pipeline architecture in which the processor is divided into separate processing stages that form the pipeline. Instructions are broken down into elemental steps that are executed in different stages in an assembly line fashion.

[0004] Pipelining refers to the simultaneous processing of multiple instructions in the pipeline. For example, if a processor executes each instruction in five stages and each stage requires a single clock cycle to perform its function, then five separate instructions can be processed simultaneously in the pipeline, with the processing of one instruction completed during each clock cycle. Hence, the instruction throughput of an N stage pipelined architecture is, in theory, N times greater than the throughput of a non-pipelined architecture that completes only one instruction every N clock cycles. However, the speed improvements provided by pipeline architectures and superpipelining processing are ultimately limited by speed at which the individual stages in the pipeline execute. It is therefore important to minimize the time required to execute each part of an instruction.

[0005] Mathematical operations often incur substantial time delays in calculating a value. Counting the number of Logic 1 bits on a data bus is a common operation encountered in computer instruction sets (e.g., ST20C2 Core Instruction Set Reference Manual, SGS-Thomson Microelectronics, November 1997) and as a component function in various digital blocks, such as memory interface units (e.g., N. J. Richardson, Private Communication). The function can serve a number of different purposes, including determining the number of valid bits set in some control logic and performing a simple error detection operation. The input to such a function is an n-bit wide bus in which an arbitrary number of bits are set to a Logic 1 value and the other bits are set to a Logic 0 value. The output for this function is a log₂(n) bit binary number equal to the number of ones on the input bus.

[0006] The problem of counting the number of ones on a bus is a simplified analog to the compression tree in a multiplier. Writing the numbers to be added as a vertical row, it is observed that the numbers represent a single column of a multiplier. Designing large multipliers is a well-known problem in digital design (See D. Goldberg, Appendix A: Computer Arithmetic in Computer Architecture—A Quantitative Approach, by J. L. Hennessy and D. A. Patterson, 2nd Edition, Morgan Kaufmann Publishers Inc., San Francisco, Calif., 1996. See also I. Koren, Computer Arithmetic Algorithms, Prentice Hall, Englewood Cliffs, N.J., 1993).

[0007] The procedure for completing the multiplication operation involves two steps. On the first step, the partial products terms are compressed to two terms. This can be done using a number of different compression schemes, including Booth encoding and various trees of full adders, 4:2 carry-save adders (CSA42s), 5:3 carry-save adders (CSA53s), 7:3 carry-save adders (CSA73s), and the like. With two partial products, the final result of the multiplication operation is calculated using a carry-propagate adder (CPA). Again, there is a large literature on the optimum design of adders, including carry-select adders, carry look-ahead adders, and the like.

[0008] Because the problem of counting the number of Logic 1 bits on a data bus is such a common operation encountered in computer instruction sets, it is important to minimize the execution time of such an operation. However, as the bus grows larger, more stages of adders are required to perform the count and more propagation delays are encountered.

[0009] A related mathematical operation is the detection of numbers equal to power of 2 on a data bus. In binary notation, a number that is a power of 2 contains one and only one Logic 1 bit. All other bits are Logic 0. Therefore, on an 8-bit bus, a power of 2 would appear as a single Logic 1 bit and seven Logic 0 bits. For example, on an 8-bit bus, 8=2³=00001000. Similarly, on an 8-bit bus, 128=2⁷=01000000. A circuit that counts the number of Logic 1 bits on an address bus or data bus can also be used to detect powers of two on the bus. Powers of two represent the special case where the count of Logic 1 bits on the bus equals one.

[0010] Therefore, there is a need in the art for data processors that minimize the execution time of common mathematical operations. In particular, there is a need for a circuit capable of rapidly determining the number of Logic 1 bits on a bus in a microprocessor, memory interface, or other data processing device. More particularly, there is a need for a Logic 1 bit counting circuit that minimizes the number of stages required to count Logic 1 bits on a data bus. Moreover, there is a need for a circuit capable of rapidly determining that there is one and only one Logic 1 bit on a bus in a microprocessor, memory interface, or other data processing device in order to detect values that are equal to a power of two.

SUMMARY OF THE INVENTION

[0011] The present disclosure uses the following abbreviations and definitions to designate adder cells:

[0012] 1. HA—Half adder. A half adder adds two input bits and provides the result as a two bit output, generally called sum (S) and carry (C). Carry has a weight of 2 and sum has a weight of 1.

[0013] 2. CSA32—Full adder. A full adder that counts three input bits and provides the result (i.e., the number of Logic 1 bit) as a two bit output. The outputs are generally called the sum and carry, with the carry having a weight of 2 and the sum of 1.

[0014] 3. CSA42—4:2 carry-save adder. A 4:2 carry-save adder is a 4-to-2 (4:2) compressor circuit that adds the result of five input bits (four regular bits and a carry-in (CIN) bit) and produces three output bits (a carry bit and a sum bit, and a carry-out (COUT) bit) for the result. The COUT bit has a weight of 2, the carry bit has a weight of 2, and the sum bit has a weight of 1.

[0015] 4. CSA53—5:3 carry-save adder. A 5:3 carry-save adder is a 5-to-3 compressor circuit that adds five input bits, three of which have bit weights of 1 and two of which have bit weights of 2. The three output bits have bit weights of 4, 2 and 1.

[0016] 5. CSA73—7:3 carry-save adder. A 7:3 carry-save adder is a 7-to-3 compressor circuit that counts seven input bits, each having a bit weight of 1. The three outputs bits have bit weights of 4, 2, and 1.

[0017] 6. CPA—Carry-propagate adder. An adder circuit that gives the binary result of adding two binary numbers.

[0018] 7. CSA43—4:3 carry-save adder. A 4:3 carry-save adder is a 4-to-3 compressor circuit that adds four input bits and provides three outputs (S2, S1, and S0) having bit weights of 4, 2 and 1, respectively. This compressor is not efficient for general purpose multiplication, but is one of a family of compressors, introduced in the present application (along with the CSA63 and CSA84), shown to have advantages when used to count the number of Logic 1 bits on a bus.

[0019] 8. CSA63—6:3 carry-save adder. A 6:3 carry-save adder is a 6-to-3 compressor circuit that adds six equally weighted input bits and produces three output bits with weights of 4, 2, and, 1, respectively.

[0020] 9. CSA84—8:4 carry-save adder. An 8:4 carry-save adder is an 8-to-4 compressor circuit with adds eight equally weighted input bits. The output bits have weights of 8, 4, 2 and 1, respectively.

[0021] To address the above-discussed deficiencies of the prior art, it is a primary object of the present invention to provide a circuit for determining if an N-bit number is equal to a power of two. According to an advantageous embodiment of the present invention, the circuit comprises: 1) a first stage of detection gates, each of the first stage detection gates capable of receiving a first data bit and a second data bit from the N-bit number and generating a first output bit and a second output bit, wherein the first and second output bits are 01 if the first and second data bits are different and are one of 00 and 11 if the first and second data bits are the same; and 2) a second stage of detection gates coupled to the outputs of the first stage of detection gates, each of the second stage detection gates receiving three of the first stage output bits and generating a first output bit and a second output bit, wherein the first and second output bits of the second stage detection gates are 01 if only one of the three first stage output bits is equal to Logic 1 and are one of 00 and 11 otherwise.

[0022] According to one embodiment of the present invention, each of the detection gates in the first stage of detection gates comprises a first multiplexer and a second multiplexer.

[0023] According to another embodiment of the present invention, the first multiplexer has a 0 input channel coupled to the first data bit, a 1 input channel coupled to a Logic 1 signal, and a channel select input coupled to the second data bit.

[0024] According to still another embodiment of the present invention, the second multiplexer has a 0 input channel coupled to a Logic 0 signal, a 1 input channel coupled to the first data bit, and a channel select input coupled to the second data bit.

[0025] According to yet another embodiment of the present invention, each of the detection gates in the second stage of detection gates comprises a first multiplexer and a second multiplexer.

[0026] According to a further embodiment of the present invention, the first multiplexer has a 0 input channel coupled to a first output bit of the first stage, a 1 input channel coupled to a Logic 1 signal, and a channel select input coupled to a second output bit of the first stage.

[0027] According to a still further embodiment of the present invention, the second multiplexer has a 0 input channel coupled to a third output bit of the first stage, a 1 input channel coupled to the first output bit of the first stage, and a channel select input coupled to the second output bit of the first stage.

[0028] According to a yet further embodiment of the present invention, each of the detection gates in the second stage of detection gates further comprises a third multiplexer and a fourth multiplexer.

[0029] In another embodiment of the present invention, the third multiplexer has a 0 input channel coupled to an output of the first multiplexer, a 1 input channel coupled to a Logic 1 signal, and a channel select input coupled to a fourth output bit of the first stage.

[0030] In still another embodiment of the present invention, the fourth multiplexer has a 0 input channel coupled to an output of the second multiplexer, a 1 input channel coupled to the output of the first multiplexer, and a channel select input coupled to the fourth output bit of the first stage.

[0031] The foregoing has outlined rather broadly the features and technical advantages of the present invention so that those skilled in the art may better understand the detailed description of the invention that follows. Additional features and advantages of the invention will be described hereinafter that form the subject of the claims of the invention. Those skilled in the art should appreciate that they may readily use the conception and the specific embodiment disclosed as a basis for modifying or designing other structures for carrying out the same purposes of the present invention. Those skilled in the art should also realize that such equivalent constructions do not depart from the spirit and scope of the invention in its broadest form.

[0032] Before undertaking the DETAILED DESCRIPTION OF THE INVENTION below, it may be advantageous to set forth definitions of certain words and phrases used throughout this patent document: the terms “include” and “comprise,” as well as derivatives thereof, mean inclusion without limitation; the term “or,” is inclusive, meaning and/or; the phrases “associated with” and “associated therewith,” as well as derivatives thereof, may mean to include, be included within, interconnect with, contain, be contained within, connect to or with, couple to or with, be communicable with, cooperate with, interleave, juxtapose, be proximate to, be bound to or with, have, have a property of, or the like; and the term “controller” means any device, system or part thereof that controls at least one operation, such a device may be implemented in hardware, firmware or software, or some combination of at least two of the same. It should be noted that the functionality associated with any particular controller may be centralized or distributed, whether locally or remotely. Definitions for certain words and phrases are provided throughout this patent document, those of ordinary skill in the art should understand that in many, if not most instances, such definitions apply to prior, as well as future uses of such defined words and phrases.

BRIEF DESCRIPTION OF THE DRAWINGS

[0033] For a more complete understanding of the present invention, and the advantages thereof, reference is now made to the following descriptions taken in conjunction with the accompanying drawings, wherein like numbers designate like objects, and in which:

[0034]FIG. 1 illustrates an exemplary processing system, namely a personal computer, that implements an improved Logic 1 counter in accordance with the principles of the present invention;

[0035]FIG. 2 illustrates in greater detail an exemplary processor according to one embodiment of the present invention;

[0036]FIG. 3 illustrates a Logic 1 counter for counting Logic 1 bits on a 16-bit bus according to one embodiment of the prior art;

[0037]FIG. 4 illustrates a Logic 1 counter for counting Logic 1 bits on a 16-bit bus and detecting values that are equal to a power of two according to one embodiment of the present invention; and

[0038]FIG. 5 illustrates a circuit for detecting a power of two value on an 8-bit bus according to an alternate embodiment of the present invention.

DETAILED DESCRIPTION OF THE INVENTION

[0039]FIGS. 1 through 5, discussed below, and the various embodiments used to describe the principles of the present invention in this patent document are by way of illustration only and should not be construed in any way to limit the scope of the invention. Those skilled in the art will understand that the principles of the present invention may be implemented in any suitably arranged data processor.

[0040]FIG. 1 illustrates an exemplary processing system, namely personal computer (PC) 100, that contains an improved Logic 1 counter in accordance with the principles of the present invention. Personal computer 100 comprises removable (i.e., floppy) disk drive (FDD) 102 and hard disk drive (HDD) 103, monitor 104, keyboard 105, processor (CPU) 106, main memory 107, and a pointing device, such as mouse 108. Monitor 104, keyboard 105, and mouse 108 may be replaced by, or combined with, other input/output (I/O) devices. Removable disk drive 102 is capable of reading and writing to removable floppy diskettes. Hard disk drive 105 provides fast access for storage and retrieval of application programs and data.

[0041] Keyboard 105 and mouse 108 are coupled to PC 100 via input/output (I/O) interface (IF) 110. Monitor 104 is coupled to pc 100 via video/audio interface (IF) 112. The internal components of PC 100, including floppy disk drive 102, hard disk drive 103, processor 106, main memory 107, I/O interface 110 and video/audio interface 112, are coupled to and communicate across communications bus 115.

[0042] In an exemplary embodiment of the present invention, main memory 107 comprises a volatile storage device, such as a dynamic random access memory (RAM). Processor 106 may comprise an on-board two level cache system, including a Level 1 (L1) cache and a Level 2 (L2) cache. The two level cache is a system in which a small, fast cache (the L1 cache) is connected to a slower, larger cache (the L2 cache). When the central processing unit (CPU) core logic of processor 106 reads or writes data to or from a memory location in main memory 107, the cache system first tests to see if the data belonging to that location is in the L1 cache. If the data is in the L1 cache, then the data is provided or updated quickly by the L1 cache. If the data is not in the L1 cache, then an L1 cache read “miss” or an L1 cache write “miss” has occurred.

[0043] The data is then provided or updated to the CPU core logic of processor 106 by the L2 cache. In the case of an L1 cache read miss, the line containing the requested data is also transferred from the L2 cache to the L1 cache, so that the data may be provided more quickly the next time processor 106 accesses the data. This is known as an Li cache line fill. If the data is also not in the L2 cache, then an L2 cache miss has occurred and the line containing the requested data is fetched from main memory 107 and then loaded into the L2 cache for faster access the next time the data is requested. This is known as an L2 cache line fill.

[0044]FIG. 2 illustrates in greater detail exemplary processor 106 according to one embodiment of the present invention. Processor 106 contains an instruction pipeline comprising instruction fetch (IF) stage 205, decode stage 210, operand fetch stage 215, execute stage 220, and write-back stage 225. Processor 106 also comprises register stack 230, instruction (INSTR.) cache 235 and data cache 240.

[0045] Processor 106 is a central processing unit (CPU) capable of fetching and interpreting instructions, retrieving data, executing instructions, and storing results. The illustrated instruction pipeline is a mechanism capable of executing several different operations concurrently. The pipeline does this by breaking down the processing steps for each major task into several discrete processing phases, each of which is executed by a separate pipeline stage. Each task must pass sequentially through each processing phase, and hence each pipeline stage, to complete its execution.

[0046] Instruction fetch stage 205 fetches instructions to be executed from instruction cache 235 and stores the fetched instructions in an instruction fetch buffer (IFB). The instructions taken from the IFB by decode stage 210 are encoded in a highly compact form. Decode stage 210 decodes the instructions into larger sets of signals that can be used directly for execution by subsequent pipeline stages. Operand fetch stage 215 fetches operands from memory or from register stack 230. Execute stage 220 performs the actual operation (e.g., add, multiply, divide, and the like) on the operands fetched by operand fetch stage 215 and generates the result. Write-back stage 225 writes the result generated by execute stage 220 into data cache 240 or into one of the registers in register stack 230.

[0047] As noted above, it is important to minimize the time required to execute each part of an instruction. In exemplary processor 106, there are a number of data buses and address buses interconnecting the functional blocks within processor 106. Many programs contain instructions that count the number of Logic 1 bits on a data bus, either for status purposes, or error checking purposes, or the like. Furthermore, some program instructions are used to detect if a number is a power of two. This can be accomplished by counting the number of Logic 1 bits on a bus and determining if the count is equal to 1. If so, then the number on the bus is a power of 2. However, as noted above, counting the number of Logic 1 bits on a data bus is a mathematical operation that may cause undue delay if the circuit that counts the Logic 1 bits is not efficiently constructed in order to minimize the number of gate delays (i.e., stages).

[0048] The present invention determines the number of Logic 1 bits on a bus (address or data) using a novel set of compressors. The present invention significantly simplifies the process of compressing the partial product terms. The resulting solution is faster, and also generally smaller and more power efficient solution than conventional solutions to the problem of determining the number of Logic 1 bits on an address or data bus.

[0049] According to the principles of the present invention, the encoding scheme involves dividing the input bus into M segments each of which are N-bits wide. A first stage of logic circuits is used to count the number of Logic 1 bits in each of these N-bit segments. Usually, N is chosen as a multiple of 4 (e.g., 8, 16, 24, 32, and the like) . While this is similar to how a traditional multiplier compressor works, the fact that the first stage of compressors work on data bits that are only a single bit wide (i.e., bit weight of 1) permits the subsequent use of compressors that generally are not favored in multipliers.

[0050] This is due to the fact that the first stage of compressors do not need to consider the compression ratio being proportional to the number of output bits. In regular multiplication, when, for example, a 4:2 carry-save adder (CSA42) gate is used in a stage, the output data is 2 bits wide. This ensures that the compression that occurs is 4 to 2 (i.e., 2-to-1 ratio). In a CSA42, there is also a carry-in (CIN) bit and carry-out (COUT) bit which are used by other gates in the same stage. Since these bits are internally generated in the row and are not available as inputs or outputs, they are not included in the compression ratio calculation.

[0051] This problem does not occur when adding data one bit wide, as there are no other rows of data which need to be tiled. Standard multiplier compressors are designed to accommodate the wide data widths present in a multiplication operation. In a one bit counter, the first compression that occurs is always down to a single bus. Thus, a CSA42 compressor actually performs compression of 4-to-1 for the first compression. After the first compression is completed, the partial products are now of width greater than one. Under these conditions, the usual compression schemes for multipliers needs to be utilized.

[0052] Another advantage of having data being one bit wide is that there are no carry-in bits. This permits the reduction of the amount of computation relative to compressors with carry-in bits. Since the first compression allows for maximum compression, there are some advantages to be garnered by making the first compressor as wide as possible. For example, a four input CSA43 may be used. For traditional multipliers, a compressor that receives 4 bits, but which gives a meager compression ration of {fraction (4/3)}=1.33, is a worse compressor than a common full adder (CSA32), and would never be used.

[0053] In general, it is advantageous to use large compressors up front. For example, a CSA84 which gives the four bit result of adding the eight inputs can be used to perform an initial 8 to 1 compression. For standard partial product compression, a CSA84 has no advantage over a CSA42 in terms of compression ration, and due to the extra circuit complexity would not be used. However, in the present invention, a CSA84 serves a very advantageous task. Other useful compressor sizes for the initial compression would be a CSA63, which takes six inputs and compresses them to three outputs.

[0054] The present invention uses novel compressors for the first stage of the compression tree and then uses standard compression circuits in subsequent stages. To demonstrate the advantages of the present invention, a prior art counter for counting Logic 1 bits on a 16-bit bus is compared to a 16-bit bus counter according to the principles of the present invention. In the prior art counter, a first stage of CSA42 adders is used. The actual optimal implementation for a particular technology may or may not use CSA42 gates, since it is dependent on the width of the data bus and the delay characteristics of the technology. The example is, however, used to demonstrate the general superiority of the present invention, irrespective of the actual compression scheme used for the partial products of width greater than 1.

[0055]FIG. 3 illustrates Logic 1 counter 300 for counting Logic 1 bits on a 16-bit bus according to one embodiment of the prior art. Logic 1 counter 300 comprises four stages of adders. A first stage comprises four 4:2 carry-save adders, namely CSA42 301, CSA42 302, CSA42 303 and CSA42 304. A second stage comprises two 4:2 carry-save adders, namely CSA42 305 and CSA42 306, and two half adders, namely HA 311 and HA 312. A third stage comprises two 4:2 carry-save adders, namely CSA42 307 and CSA42 308, and a half adder, namely HA 313. The fourth stage is 4-bit carry-propagate adder (CPA) 321, which receives a 3-bit argument on a first 4-bit input and a second 4-bit argument on a second 4-bit input. The sum of the two arguments is a five bit result at the output of 4-bit adder 321.

[0056] In the prior art circuit, a tree of CSA42 cells is used to compress the 16 bits received from a bus to a sum and carry term. In the first stage, four CSA42 cells operate in parallel and reduce the number of partial products to eight. The reason there are eight partial product terms is that each CSA42 cell produces a carry bit and a carry-out bit, both of which have weights of 2. Since we have four CSA42 cells, we have eight terms of the same weight. The second stage uses two CSA42 cells and two HA cells in parallel to reduce to four partial products.

[0057] The third stage uses two CSA42 cells and one HA cell to produce two 4-bit outputs. The final addition uses a 4-bit CPA with a carry-out bit. In some process technologies, the delay of a CSA42 cell may be 0.72 nanoseconds and the delay of a CPA adder may be 0.77 nanoseconds. Since the critical path in Logic 1 counter 300 is three CSA42 cells followed by a 4-bit CPA, the total delay is 2.93 nanoseconds (0.72+0.72+0.72+0.77).

[0058]FIG. 4 illustrates Logic 1 counter 400 for counting Logic 1 bits on a 16-bit bus and detecting numbers equal to a power of two according to one embodiment of the present invention. Logic 1 counter 400 comprises three stages of adders. A first stage comprises four 4:3 carry-save adders, namely CSA43 401, CSA43 402, CSA43 403 and CSA43 404. A second stage comprises three 4:2 carry-save adders, namely CSA42 411, CSA42 412, and CSA42 413. The third stage is 4-bit carry-propagate adder (CPA) 421, which receives a 3-bit argument on a first 4-bit input and a second 4-bit argument on a second 4-bit input. The sum of the two arguments is a five bit result at the output of 4-bit CPA 421.

[0059] By using four CSA43 cells for the first stage, it is possible to reduce the 16 partial products to four. In the second stage, three CSA42 cells operate in parallel to reduce the result to two partial products. A 4-bit CPA cell generates the final result. A synthesized CSA43 cell may have a delay of 0.48 nanoseconds in a typical fabrication process. Logic 1 counter 400 has a critical path of one CSA43 cell, one CSA42 cell, and one 4-bit CPA. This equals a total delay of 1.97 nanoseconds (0.48+0.72+0.77), which is faster that the prior art counter. The design uses four CSA43 cells and three CSA42 cells compared to eight CSA42 cells and 2 HA adders in the prior art design. Since the CSA43 cell has approximately the same complexity as a CSA42 cell, the new design is also smaller and consumes less power.

[0060] Alternately, Logic 1 counter 400 could have been implemented with full adders (or CSA32 cells) and half adders. For a prior art implementation with those cells, the first stage would use four CSA32 cells and one HA cells in parallel. The second stage would use two CSA32 cells and 2 HA cells. The third stage of compression would use one CSA32 cell and 2 HA cells. The fourth and final stage would need one CSA32 cell and one HA cell. Finally a 4-bit CPA would be needed to complete the function. The critical path would thus be four CSA32 cells and a 4-bit carry-propagate adder. A typical CSA32 cell has a delay of 0.32nS. Thus, the full delay is 2.05 nanoseconds.

[0061] On the other hand, using CSA43 cells in the first stage according to the principles of the present invention, the first stage compression could be performed with four CSA43 cells. The second stage would use four CSA32 cells. The third stage would need two CSA32 cells and a HA cell before passing the result on to the 4-bit CPA. The critical path in this case is one CSA43 cell, two CSA32 cells, and the CPA, which give a delay of 1.89 nanoseconds. Again, the use of the new first stage compressor results in a faster implementation. In terms of cell count, the pure CSA32 solution requires eight CSA32 cells, six HA cells, and a 4-bit CPA. The solution according to the present invention using CSA43 cells needs four CSA43 cells, six CSA32 cells, one HA cell and a 4-bit CPA.

[0062] The two examples in the previous subsection show speedups of 36% and 8% in using the CSA43 compressor for counting the number of Logic 1 bits on a bus. The actual speed improvements vary depending on the bus width, the fabrication technology, and the compression scheme being used.

[0063] In addition to the CSA43 cell described herein, the CSA63 cell and the CSA84 cell are also useful in the first compression stage. In general, one can extend the result to a CSApq cell, where p input bits are compressed to q output bits. The basic result of the present invention is that for the first compression stage of an application where the partial products have a width of one, the actual compression achieved is p/1 and not p/q. Thus, a whole host of p values and q values can be used which would not necessarily be of any advantage in regular multiplication where the partial product widths are always greater than 1.

[0064] Logic 1 counter 400 can also be used to detect numbers equal to a power of 2. This can be done by comparing the result counted by Logic 1 counter 400 with the value 1. If the count of Logic 1 bits on a data bus is equal to 1, then that number on the data bus is a power of 2. However, Logic 1 counter 400 is not the only type of circuit that may be used to determine that one and only one bit on a data bus is equal to Logic 1 (i.e., number on data bus is a power of 2). Other circuits are capable of determining that one and only one bit on a data bus is equal to Logic 1.

[0065]FIG. 5 illustrates circuit 500 for detecting a power of two value on an 8-bit bus according to an alternate embodiment of the present invention. Circuit 500 comprises a plurality of multiplexers arranged in three stages. The first stage comprises multiplexers (MUXs) 501-508. The second stage comprises multiplexers (MUXs) 521-524 and multiplexers (MUXs) 531-534. The third stage comprises multiplexers (MUXs) 541-544.

[0066] The first stage of eight multiplexers (MUX 501 through MUX 508) receives data bits D0 to D7 from the 8-bit bus. MUX 501 through MUX 508 are organized as four pairs of multiplexers. Each pair of multiplexers receives two data bits and produces a 2-bit result that indicates one or three states: that the two received data bits contain no Logic 1 bits, that the two received data bits contain only one Logic 1 bit, or that the two received data bits contain two Logic 1 bits.

[0067] The present invention may be better understood by describing the operation of MUX 507 and MUX 508. The D1 bit is used as a MUX select signal on MUX 507 and MUX 508. When D1=0, the 0 channel is selected on MUX 507 and MUX 508. When D1=1, the 1 channel is selected on MUX 507 and MUX 508. The 0 channel of MUX 507 is connected to Logic 0 (i.e., tied low). The 1 channel of MUX 507 is connected to the D0 bit. The 0 channel of MUX 508 is connected to the D0 bit. The 1 channel of MUX 508 is connected to Logic 1 (i.e., tied high). The output of MUX 507 is the result 1. The output of MUX 508 is the result P0. TABLE 1 below is a truth table defining the operation of MUX 507 and MUX 508: TABLE 1 D1 D0 | P1 P0 0 0 | 0 0 0 1 | 0 1 1 0 | 0 1 1 1 | 1 1

[0068] If (D1,D0)=00 (i.e., both Logic 0), then (P1,PO)=00. If (D1,D0)=11 (i.e., both Logic 1), then (P1,P0)=11. If one and only one of D1 and D0 are equal to Logic 1 (i.e., 01 or 10), then (P1,P0)=01. Thus, the outputs of MUX 507 and MUX 508, namely P1 and P0, have only three states: 00, 01 and 11. The state (P1,P0)=10 does not occur.

[0069] The operations of the other three pairs of multiplexers (i.e., MUX 501 and MUX 502, MUX 503 and MUX 504, and MUX 506 and MUX 507) in the first stage are identical to the operation of MUX 507 and MUX 508. This being the case, each of the output pairs of the other three multiplexer pairs also has only three states, namely 00, 01 and 11. The state (P7, P6)=10 does not occur, the state (P5, P4)=10 does not occur, and the state (P3, P2)=10 does not occur.

[0070] The second stage of multiplexers, MUX 521-524 and MUX 531-534, receives the result bits P0 through P7 from the first stage of multiplexers. MUX 521-524 operate on P7-P4 to produce two result bits, Q3 and Q2. MUX 531-534 operate on P3-P0 to produce two result bits, Q1 and Q0.

[0071] The operation of the second stage may be better understood by describing the operation of MUX 531-MUX 534. The P3 bit is used as a MUX select signal on MUX 533 and MUX 534. The P2 bit is used as a MUX select signal on MUX 531 and MUX 532. The 1 channel of MUX 532 is connected to Logic 1 (i.e., tied high). The 0 channel of MUX 532 is connected to the P0 bit. The 0 channel of MUX 531 is connected to the P1 bit. The 1 channel of MUX 531 is connected to the P0 bit. The output of MUX 531 is applied to the 0 channel of MUX 533. The output of MUX 532 is applied to the 1 channel of MUX 533 and the 0 channel of MUX 534. The 1 channel of MUX 534 is set to Logic 1.

[0072] The output of MUX 533 is the result Q1. The output of MUX 534 is the result Q0. TABLE 2 below is a truth table defining the operation of MUX 531-MUX 534. Dashed entries indicate (1,0) states in a standard Boolean truth table that are disallowed because neither (P3, P2) nor (P1,P0) can ever be equal to 10: TABLE 2 P3 P2 P1 P0 | Q1 Q0 0 0 0 0 | 0 0 0 0 0 1 | 0 1 — — — — | — — 0 0 1 1 | 1 1 0 1 0 0 | 0 1 0 1 0 1 | 1 1 — — — — | — — 0 1 1 1 | 1 1 — — — — | — — — — — — | — — — — — — | — — — — — — | — — 1 1 0 0 | 1 1 1 1 0 1 | 1 1 — — — — | — — 1 1 1 1 | 1 1

[0073] If (P3, P2, P1, P0)=0000, then (Q1, Q0)=00. If two or more of P3, P2, P1 and P0=1, then (Q1, Q0)=11. If one and only one of P3, P2, P1 and P0=1, then (Q1, Q0)=01. Thus, the outputs of MUX 533 and MUX 534, namely Q1 and Q0, have only three states: 00, 01 and 11. The state (Q1, Q0)=10 does not occur.

[0074] The operations of MUX 521, MUX 522, MUX 523 and MUX 524 are identical to the operations of MUX 531, MUX 532, MUX 533 and MUX 534. This being the case, Q3 and Q2 also have only three states, namely 00, 01 and 11. The state (Q3, Q2)=10 does not occur.

[0075] The third stage of multiplexers, MUX 541-MUX 544, receives the result bits Q0, Q1, Q2, and Q3 from the second stage of multiplexers. MUX 541-MUX 544 operate on Q3-Q0 to produce two result bits, R1 and R0. The operations of MUX 541, MUX 542, MUX 543 and MUX 544 are identical to the operations of MUX 531, MUX 532, MUX 533 and MUX 534 in the second stage. TABLE 3 below is a truth table defining the operation of MUX 541-MUX 544. Dashed entries indicate (1, 0) states in a standard Boolean truth table that are disallowed because neither (Q3, Q2) nor (Q1, Q0) can ever be equal to 10: TABLE 3 Q3 Q2 Q1 Q0 | R1 R0 0 0 0 0 | 0 0 0 0 0 1 | 0 1 — — — — | — — 0 0 1 1 | 1 1 0 1 0 0 | 0 1 0 1 0 1 | 1 1 — — — — | — — 0 1 1 1 | 1 1 — — — — | — — — — — — | — — — — — — | — — — — — — | — — 1 1 0 0 | 1 1 1 1 0 1 | 1 1 — — — — | — — 1 1 1 1 | 1 1

[0076] In sum, if (R1, R0)=01, then there is exactly one Logic 1 bit in data bits D0 to D7 on the 8-bit bus, which means the number on the 8-bit bus is a power of two. If (R1, R0)=11, then there is more than one Logic 1 bit in data bits D0 to D7 and the number on the 8-bit bus is not a power of two. If (R1, R0)=00, then there are no Logic 1 bits in data bits D0 to D7 and the number on the 8-bit bus is zero. As before, the state (R1, R0)=10 cannot occur. The (R1, R0) result bits can be reduced to a single flag bit indicating that the number on D7:D0 is a power of two by applying R1 and R0 to an exclusive-OR gate.

[0077] It is important to note that the input data bits, D0 through D7, do not need to be applied to the input multiplexers in sequential order. That is, adjacent data bits, such as D2 and D2 or D6 and D7, do not have to be processed by the same one of MUX 501-MUX 508. Even if data bits D0 through D7 are applied randomly to MUX 501-MUX 508, the present invention still operates to determine if D7:D0 is a power of two.

[0078] Although the present invention has been described in detail, those skilled in the art should understand that they can make various changes, substitutions and alterations herein without departing from the spirit and scope of the invention in its broadest form. 

What is claimed is:
 1. A circuit for determining if an N-bit number is equal to a power of two comprising: a first stage of detection gates, each of said first stage detection gates capable of receiving a first data bit and a second data bit from said N-bit number and generating a first output bit and a second output bit, wherein said first and second output bits are 01 if said first and second data bits are different and are one of 00 and 11 if said first and second data bits are the same; and a second stage of detection gates coupled to said outputs of said first stage of detection gates, each of said second stage detection gates receiving three of said first stage output bits and generating a first output bit and a second output bit, wherein said first and second output bits of said second stage detection gates are 01 if only one of said three first stage output bits is equal to Logic 1 and are one of 00 and 11 otherwise.
 2. The circuit as set forth in claim 1 wherein each of said detection gates in said first stage of detection gates comprises a first multiplexer and a second multiplexer.
 3. The circuit as set forth in claim 2 wherein said first multiplexer has a 0 input channel coupled to said first data bit, a 1 input channel coupled to a Logic 1 signal, and a channel select input coupled to said second data bit.
 4. The circuit as set forth in claim 3 wherein said second multiplexer has a 0 input channel coupled to a Logic 0 signal, a 1 input channel coupled to said first data bit, and a channel select input coupled to said second data bit.
 5. The circuit as set forth in claim 1 wherein each of said detection gates in said second stage of detection gates comprises a first multiplexer and a second multiplexer.
 6. The circuit as set forth in claim 5 wherein said first multiplexer has a 0 input channel coupled to a first output bit of said first stage, a 1 input channel coupled to a Logic 1 signal, and a channel select input coupled to a second output bit of said first stage.
 7. The circuit as set forth in claim 6 wherein said second multiplexer has a 0 input channel coupled to a third output bit of said first stage, a 1 input channel coupled to said first output bit of said first stage, and a channel select input coupled to said second output bit of said first stage.
 8. The circuit as set forth in claim 7 wherein each of said detection gates in said second stage of detection gates further comprises a third multiplexer and a fourth multiplexer.
 9. The circuit as set forth in claim 8 wherein said third multiplexer has a 0 input channel coupled to an output of said first multiplexer, a 1 input channel coupled to a Logic 1 signal, and a channel select input coupled to a fourth output bit of said first stage.
 10. The circuit as set forth in claim 9 wherein said fourth multiplexer has a 0 input channel coupled to an output of said second multiplexer, a 1 input channel coupled to said output of said first multiplexer, and a channel select input coupled to said fourth output bit of said first stage.
 11. A data processor comprising: an instruction execution pipeline comprising N processing stages, each of said N processing stages capable of performing one of a plurality of execution steps associated with a pending instruction being executed by said instruction execution pipeline, wherein at least one of said N processing stages comprises a circuit for determining if an N-bit number is equal to a power of two, said circuit comprising: a first stage of detection gates, each of said first stage detection gates capable of receiving a first data bit and a second data bit from said N-bit number and generating a first output bit and a second output bit, wherein said first and second output bits are 01 if said first and second data bits are different and are one of 00 and 11 if said first and second data bits are the same; and a second stage of detection gates coupled to said outputs of said first stage of detection gates, each of said second stage detection gates receiving three of said first stage output bits and generating a first output bit and a second output bit, wherein said first and second output bits of said second stage detection gates are 01 if only one of said three first stage output bits is equal to Logic 1 and are one of 00 and 11 otherwise.
 12. The data processor as set forth in claim 11 wherein each of said detection gates in said first stage of detection gates comprises a first multiplexer and a second multiplexer.
 13. The data processor as set forth in claim 12 wherein said first multiplexer has a 0 input channel coupled to said first data bit, a 1 input channel coupled to a Logic 1 signal, and a channel select input coupled to said second data bit.
 14. The data processor as set forth in claim 13 wherein said second multiplexer has a 0 input channel coupled to a Logic 0 signal, a 1 input channel coupled to said first data bit, and a channel select input coupled to said second data bit.
 15. The data processor as set forth in claim 14 wherein each of said detection gates in said second stage of detection gates comprises a first multiplexer and a second multiplexer.
 16. The data processor as set forth in claim 15 wherein said first multiplexer has a 0 input channel coupled to a first output bit of said first stage, a 1 input channel coupled to a Logic 1 signal, and a channel select input coupled to a second output bit of said first stage.
 17. The data processor as set forth in claim 16 wherein said second multiplexer has a 0 input channel coupled to a third output bit of said first stage, a 1 input channel coupled to said first output bit of said first stage, and a channel select input coupled to said second output bit of said first stage.
 18. The data processor as set forth in claim 17 wherein each of said detection gates in said second stage of detection gates further comprises a third multiplexer and a fourth multiplexer.
 19. The data processor as set forth in claim 18 wherein said third multiplexer has a 0 input channel coupled to an output of said first multiplexer, a 1 input channel coupled to a Logic 1 signal, and a channel select input coupled to a fourth output bit of said first stage.
 20. The data processor as set forth in claim 19 wherein said fourth multiplexer has a 0 input channel coupled to an output of said second multiplexer, a 1 input channel coupled to said output of said first multiplexer, and a channel select input coupled to said fourth output bit of said first stage. 